package com.ymatou.app.testcase;

import java.util.ArrayList;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.app.parameter.LiveProductIdsBean;
import com.ymatou.app.service.LiveProductIdsCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.SellerCallService;

public class Ts_LiveProductIds {
	
	private static LiveProductIdsBean liveProductidsBean = null;
	private static LiveProductIdsCall liveProductIdsCall = null;
	private static SellerCallService sellerCallService = null;
	private int activityId = 0;
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商品列表接口");
		sellerCallService = new SellerCallService("zhangyi_seller002", "123456");
	}

	@Before
	public void caseUp() {
		liveProductIdsCall = new LiveProductIdsCall();
		liveProductidsBean = new LiveProductIdsBean();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(liveProductIdsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LiveProductIds_001() {
		Logger.start(true,"验证直播商品数量");
		try {
			Logger.comment("创建直播");
			sellerCallService.createActivity();
			
			activityId = sellerCallService.getActivityInProgress();
			
			Logger.comment("添加三个商品");
			sellerCallService.createProduct(activityId, 5);
			
			Thread thread = Thread.currentThread();
			thread.sleep(15000);
			
			Logger.comment("直播验证");
			liveProductidsBean.setLiveid(activityId);
			liveProductidsBean.setBrandids(new ArrayList<Integer>());
			liveProductidsBean.setCategoryids(new ArrayList<Integer>());
			
			liveProductIdsCall.setData(liveProductidsBean);
			liveProductIdsCall.callService();		
			Logger.comment("activityCall send:" + liveProductIdsCall.getEntityString());
			Logger.comment("activityCall response:" + liveProductIdsCall.getReturnData());
			
			Logger.verifyEquals(3, liveProductIdsCall.getLiveProductList().length(), "验证直播商品数量");	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}
